﻿using System;
using System.ComponentModel;
using System.Drawing;
using ArtMath.Core.Data;
using ArtMath.Setting;
using ArtMath.Data;
using ArtMath.Attribute;
using ArtMath.PointCollection;
using ArtMath.Resource;
using ArtMath.CommonType;

namespace ArtMath.Component.Point
{
    /// <summary>
    /// 直角坐标点
    /// </summary>
    [Serializable]
    public class RPoint_Fixed : RPointBase
    {
        [NonSerialized]
        bool constructorXY;
        public RPoint_Fixed(SketchPad pad, string name, string x, string y, bool addToList = true) : this(pad, name, addToList)
        {
            X.SetExpression(x);
            Y.SetExpression(y);
            constructorXY = true;
        }
        public RPoint_Fixed(SketchPad pad, string name, bool addToList = true) : base(pad, name, ToolTypeName.zbd, addToList)
        {
            OutlineColor = Settings.Instance.FixedPointOutlineColor;
            FillColor = Settings.Instance.FixedPointFillColor;
        }

        [MultilingualCategory("Structure"), ReadOnly(true)]
        public override PadStringX X
        {
            get
            {
                return base.X;
            }

            set
            {
                base.X = value;
            }
        }
        [MultilingualCategory("Structure"), ReadOnly(true)]
        public override PadStringX Y
        {
            get
            {
                return base.Y;
            }

            set
            {
                base.Y = value;
            }
        }
        [Browsable(false)]
        public override RPointS RotateCenter
        {
            get
            {
                return base.RotateCenter;
            }

            set
            {
                base.RotateCenter = value;
            }
        }
        [Browsable(false)]
        public override AngleStringX RotateAngle
        {
            get
            {
                return base.RotateAngle;
            }

            set
            {
                base.RotateAngle = value;
            }
        }
        [DefaultValue(typeof(Color), "194, 195, 201")]
        public override Color OutlineColor
        {
            get
            {
                return base.OutlineColor;
            }

            set
            {
                base.OutlineColor = value;
            }
        }
        [DefaultValue(typeof(Color), "232, 232, 236")]
        public override Color FillColor
        {
            get
            {
                return base.FillColor;
            }

            set
            {
                base.FillColor = value;
            }
        }
        public override bool Movable
        {
            get
            {
                return ObjectState != ObjectState.Normal;
            }
        }
        public override PointCollectionsManager GetMoveSpace(Base sender = null)
        {
            return new PointCollectionsManager(new DiscontinuityPoint(NewXY));
        }
        public override void CreateComponents()
        {
            if (!constructorXY)
            {
                ForceMove(SpareCoordinate_, false);
            }
            base.CreateComponents();
        }
    }
}
